require(["../../conf/config.js"],function(){
	require(["jquery","swiper","template","jquery-cookie","common"],function($,Swiper,template,jqcookie,com){
		console.log("加载成功");
		let allstr = getCookie("userlist");
		let allc = JSON.parse(allstr);
		allc.forEach((item)=>{
			
			if(item.status==1){
				item.asum = 0;
				item.shopcar.forEach((ite)=>{
					item.asum += ite.num;
				})
				$("#nav-li2 a span").html(item.asum);
				$("#cla1").html(item.vipname);
				$("#cla1").mouseenter(function(){
					$(".back").css({display:"block"})
				})
				$(".back").mouseleave(function(){
					$(".back").css({display:"none"})
				})
				
			}else{
				$("#cla1").html("亲，请登录");
			}
		})
		$(".back").click(function(){
				allc.forEach((item)=>{
					item.status = 0;console.log("s0");
				})		
				setCookie("userlist",JSON.stringify(allc),30);
				window.location.replace("http://localhost:8000/pages/index/index.html");
		})
			
		$("#fixed .fixed1").click(function(){
			//console.log($(this));	
			$(this).animate({left:"-190px"},800,function(){
				$("#fixed .fixed2").animate({width:"100%"},800,function(){
					$("#fixed span").css("display","block");
				});
			});
		})
		$("#fixed span").click(function(){
			$("#fixed span").css("display","none");
			$("#fixed .fixed2").animate({width:0},1000,function(){
				$("#fixed .fixed1").animate({left:0},1000,function(){			
				});
			});
		})
		
		//lunbo
		
			var mySwiper = new Swiper ('.swiper-container', {
			  loop: true,
			  autoplay:true,
			  navigation: {
			    nextEl: '.swiper-button-next',
			    prevEl: '.swiper-button-prev',
			  },		  
			  // 如果需要滚动条
			  scrollbar: {
			    el: '.swiper-scrollbar',
			  },
			})        
	
		// a b c d e
		
		//black 覆盖模板
		//  $.getJSON("http://localhost:8000/static/json/speed.json", function(data){
		//     //这个template是art-templatede中有的函数，他有2个参数，
		// 	//第一个是script标签的id，第二个参数是模板中需要循环遍历的对象和其值
		//             const htmlstr = template("list_temp2", {list : data.res_body.data});
		//             $(".bt1").html(htmlstr);
		// })
		function throttle(fn,interval){  //防抖大师 出品--节流
			let start= new Date().getTime();
			return function(){
				let now =  new Date().getTime();
				if(now-start>interval){
					fn();
					start = now;
				}
			}	
		}
		$("#playnowall li").mouseenter(function(){			
			var index = $(this).index();
			// let indexa = index+1;
			//console.log(index);
			$(this).children().last().animate({top:"10px"},200);
			var a = index;
			var b = "bt"+(index+1);		
			$.getJSON("http://localhost:8000/pages/movie/speed1.json",(data)=>{	
				var htmlstr = 
				`<ul>
					<li class="main">导演：${data[a].director}</li>
					<li class="main">主演：${data[a].actors}</li>
					<li class="main">类型：${data[a].kind}</li>
					<li class="main">地区：${data[a].area}</li>
					<li class="main">语言：${data[a].language}</li>
					<li class="main">片长：${data[a].time}</li>
			    </ul>`;
				$(this).children().last().html(htmlstr) ;				
			})
		});
		$("#playnowall li").mouseleave(function(){
			var index = $(this).index(); 
			$(this).children().last().animate({top:"-224px"},200);
		});
		  
		//new data
		$("#newdatacen").css({backgroundImage:"https://img.alicdn.com/bao/uploaded/i4/TB1vb2Ce7T2gK0jSZPcXXcKkpXa_.jpg_220x330.jpg"})
		
			
		
		
		
	});
});